package com.outsource.framework.util.common;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils
{
	public static Date getNextMonth()
	{
		Calendar c = Calendar.getInstance();
		c.add(Calendar.MONDAY, 1);
		return c.getTime();
	}
	public static Integer getUpMonth(){
		Calendar c = Calendar.getInstance();
		c.add(Calendar.MONDAY, 0);
		return c.get(Calendar.MONTH);
	}
	public static Integer getMinMonth(){
		return Calendar.getInstance().getMinimum(Calendar.DAY_OF_MONTH);
	}
	public static Integer getMaxMonth(){
		Calendar c = Calendar.getInstance();
		c.add(Calendar.MONDAY, -1);
		return c.getMaximum(Calendar.DAY_OF_MONTH);
	}
	public static Integer getYear()
	{
		return Calendar.getInstance().get(Calendar.YEAR);
	}
	public static Integer getMonth()
	{
		return Calendar.getInstance().get(Calendar.MONTH)+1;
	}
	public static Integer getDay()
	{
		return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
	}
	public static Integer getUpDay()
	{
		return Calendar.getInstance().get(Calendar.DAY_OF_MONTH)-1;
	}
	public static Date parseY_M_D(String ymd)
	{
		try
		{
			return sdfY_M_D.parse(ymd);
		} catch (ParseException e)
		{
			e.printStackTrace();
		}
		return null;
	}
	public static Date parseYMD(String ymd)
	{
		try
		{
			return sdfYMD.parse(ymd);
		} catch (ParseException e)
		{
			e.printStackTrace();
		}
		return null;
	}
	public static String formartYMD(Date date)
	{
		return sdfYMD.format(date);
	}
	public static String formartY_M_D(Date date)
	{
		return sdfY_M_D.format(date);

	}
	public static String formart(Date date){
		return sdfYMDHms2.format(date);
	}

	public static String formartYMDHms(Date date)
	{
		return sdfYMDHms2.format(date);
	}

	private static final SimpleDateFormat sdfY_M_D = new SimpleDateFormat(
			"yyyy-MM-dd");
	private static final SimpleDateFormat sdfYMD = new SimpleDateFormat(
			"yyyyMMdd");
	private static final SimpleDateFormat sdfYMDHms = new SimpleDateFormat(
			"yyyyMMddHHmmss");
	private static final SimpleDateFormat  sdfYMDHms2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
}

